/**
 * Shared CSS for AITOPIA Store
 *
 * Used by:
 *   - public/store.html (main store)
 *   - public/agent/*.html (static detail pages)
 *   - public/category/*.html (static category pages)
 *
 * This ensures visual consistency across all store pages.
 * Works alongside Tailwind CDN - these are additions/overrides.
 */

/* =============================================================================
   CSS CUSTOM PROPERTIES
   ============================================================================= */

/* Light mode (default) */
:root {
  /* Panel system */
  --panel: #F2F5F9;
  --panel-input: #EAEFF6;
  --panel-border: rgba(217, 217, 217, 0.2);
  --panel-hover: #dde4ed;

  /* Background & Foreground */
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 3.9%;

  /* Primary (Purple) */
  --primary: 271 83% 57%;
  --primary-foreground: 0 0% 100%;

  /* Secondary */
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;

  /* Muted */
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;

  /* Border */
  --border: 214.3 31.8% 91.4%;

  /* Promo / Campaign color tokens */
  --promo-yellow: #FFD91F;
  --promo-yellow-fg: #1a1000;
  --promo-bar-bg: #FFCC00;
  --promo-bar-badge-bg: #68591A;
  --promo-bar-text: #262626;
  --promo-nav-badge-bg: #F9D300;
  --promo-nav-badge-text: #0C0C0C;
  --promo-purple: hsl(var(--primary));
  --promo-purple-fg: hsl(var(--primary-foreground));

  /* Plan card tokens (light mode) */
  --plan-premium-accent: hsl(var(--primary));
  --plan-premium-accent-subtle: hsl(var(--primary) / 0.15);
  --plan-premium-fg: hsl(var(--primary-foreground));
  --plan-premium-outer-bg: hsl(var(--primary));
  --plan-premium-card-bg: hsl(var(--card));
  --plan-premium-inner-bg: hsl(var(--primary) / 0.08);
  --plan-premium-inner-border: hsl(var(--primary) / 0.2);

  --plan-creator-accent: #FFD515;
  --plan-creator-fg: #1a1000;
  --plan-creator-outer-bg: #FFD515;
  --plan-creator-card-bg: #FFFDE7;
  --plan-creator-inner-bg: #FFFBCC;
  --plan-creator-inner-border: #FFE97A;

  --plan-default-title: #111118;
  --plan-default-outer-bg: #F6F6F6;
  --plan-default-outer-border: #F6F6F6;
  --plan-default-card-bg: #F6F6F6;
  --plan-default-inner-bg: #F3F5F9;
  --plan-default-inner-border: #D9D9D9;
  --plan-default-btn-text: #111118;
  --plan-default-btn-border: #d1d5db;
  --plan-divider: rgba(0,0,0,0.1);

  /* Mobile compare panel tokens */
  --compare-heading: #111118;
  --compare-text: #374151;
  --compare-sub: #9ca3af;
  --compare-badge: #6b7280;
  --compare-border: rgba(0,0,0,0.07);
  --compare-surface: rgba(0,0,0,0.03);

  /* Upgrade widget tokens (light mode) */
  --upgrade-gold: #8B6914;
  --upgrade-purple: hsl(var(--primary));
  --upgrade-pill-border: rgba(124,58,237,0.2);
  --upgrade-surface: #F3F4F6;
  --upgrade-feature-text: #374151;
  --upgrade-title-text: #111118;
  --upgrade-strip-border: rgba(0,0,0,0.08);

  /* Countdown banner tokens (light mode) */
  --cd-banner-bg: linear-gradient(135deg, #FFF0B8 0%, #FDE992 50%, #FFF0B8 100%);
  --cd-banner-border: rgba(0,0,0,0.06);
  --cd-badge-bg: rgba(0,0,0,0.07);
  --cd-badge-border: rgba(0,0,0,0.12);
  --cd-badge-color: #7A5C00;
  --cd-heading: #1A1200;
  --cd-desc: #5C4D00;
  --cd-right-bg: rgba(0,0,0,0.05);
  --cd-right-border: rgba(0,0,0,0.06);
  --cd-title: #7A5C00;
  --cd-unit-bg: rgba(0,0,0,0.06);
  --cd-unit-border: rgba(0,0,0,0.1);
  --cd-accent: #7A5C00;
  --cd-accent-dim: rgba(90,70,0,0.6);
  --cd-sep: rgba(90,70,0,0.35);

  /* Pricing page text tokens (light mode) */
  --pricing-title: #0C0C0C;
  --pricing-subtitle: #4B4B4B;
  --pricing-toggle-color: #6b7280;
  --pricing-toggle-active: #0C0C0C;

  /* iOS System Colors */
  --ios-blue: #007AFF;
  --ios-green: #34C759;
  --ios-orange: #FF9500;
  --ios-red: #FF3B30;
  --ios-purple: #AF52DE;
  --ios-teal: #5AC8FA;
}

/* Dark mode */
.dark {
  /* Panel system */
  --panel: #0F0F0F;
  --panel-input: #141414;
  --panel-border: #171717;
  --panel-hover: #1A1C1F;

  /* Upgrade widget tokens (dark mode overrides) */
  --upgrade-gold: #d4af37;
  --upgrade-purple: hsl(var(--primary));
  --upgrade-pill-border: #2C2C2C;
  --upgrade-surface: #181A1B;
  --upgrade-feature-text: #e5e7eb;
  --upgrade-title-text: #ffffff;
  --upgrade-strip-border: rgba(128,128,128,0.12);

  /* Plan card tokens (dark mode overrides) */
  --plan-premium-card-bg: hsl(var(--card));
  --plan-premium-inner-bg: hsl(var(--primary) / 0.1);
  --plan-premium-inner-border: hsl(var(--primary) / 0.3);

  --plan-creator-card-bg: #15120a;
  --plan-creator-inner-bg: #1C1B13;
  --plan-creator-inner-border: #47400F;

  --plan-default-title: #E6E6E6;
  --plan-default-outer-bg: #121416;
  --plan-default-outer-border: #121416;
  --plan-default-card-bg: #121416;
  --plan-default-inner-bg: rgba(255,255,255,0.03);
  --plan-default-inner-border: rgba(255,255,255,0.08);
  --plan-default-btn-text: #E6E6E6;
  --plan-default-btn-border: #374151;
  --plan-divider: rgba(255,255,255,0.08);

  /* Mobile compare panel tokens (dark overrides) */
  --compare-heading: #E6E6E6;
  --compare-text: #d1d5db;
  --compare-sub: #6b7280;
  --compare-badge: #9ca3af;
  --compare-border: rgba(255,255,255,0.05);
  --compare-surface: rgba(255,255,255,0.04);
  /* Countdown banner tokens (dark overrides) */
  --cd-banner-bg: #1D1B17;
  --cd-banner-border: rgba(255,255,255,0.03);
  --cd-badge-bg: rgba(212,175,55,0.12);
  --cd-badge-border: rgba(180,150,30,0.45);
  --cd-badge-color: #FCD34D;
  --cd-heading: #FFCC00;
  --cd-desc: #9D9292;
  --cd-right-bg: #2A281F;
  --cd-right-border: rgba(255,255,255,0.03);
  --cd-title: #FCD34D;
  --cd-unit-bg: #443C25;
  --cd-unit-border: rgba(180,150,30,0.4);
  --cd-accent: #d4af37;
  --cd-accent-dim: rgba(212,175,55,0.45);
  --cd-sep: rgba(212,175,55,0.3);

  /* Pricing page text tokens (dark overrides) */
  --pricing-title: #E6E6E6;
  --pricing-subtitle: #909091;
  --pricing-toggle-color: #6b7280;
  --pricing-toggle-active: #E6E6E6;

  /* Background & Foreground - #0f1113 */
  --background: 210 12% 7%;
  --foreground: 0 0% 98%;
  --card: 0 0% 6%; /* #0F0F0F */
  --card-foreground: 0 0% 98%;

  /* Primary (Purple) */
  --primary: 271 83% 57%;
  --primary-foreground: 0 0% 100%;

  /* Secondary */
  --secondary: 0 0% 15%;
  --secondary-foreground: 0 0% 98%;

  /* Muted */
  --muted: 0 0% 15%;
  --muted-foreground: 0 0% 64%;

  /* Border */
  --border: 0 0% 18%;
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}

@layer base {
  button:not(:disabled),
  [role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
  }
}

/* Override Tailwind dark:bg-neutral-950 to use #0A0A0A */
.dark body,
.dark .bg-neutral-950,
body.dark,
html.dark body,
html.dark body.bg-white,
.dark body.min-h-screen {
  background-color: #0A0A0A !important;
}

/* Force header background in dark mode */
.dark header,
.dark header.glass,
html.dark header {
  background-color: #0A0A0A !important;
}

/* =============================================================================
   GLASSMORPHISM
   ============================================================================= */

.glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.dark .glass {
  background: #0A0A0A;
}

.glass-light {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.agent-tab-row-btn {
  background-color: #F2F5F9;
  border: 1px solid rgba(217, 217, 217, 0.2);
}

.dark .agent-tab-row-btn {
  background-color: #121212;
  border-color: rgba(217, 217, 217, 0.04);
}

/* =============================================================================
   iOS-STYLE COMPONENTS
   ============================================================================= */

/* App Icon (iOS rounded square) */
.app-icon {
  border-radius: 22.37%;
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.15);
}

.dark .app-icon {
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Card hover effect */
.card-hover {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
}

.dark .card-hover:hover {
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.4);
}

.card-hover:active {
  transform: scale(0.98);
}

/* Button press effect */
.btn-press {
  transition: transform 0.15s ease;
}

.btn-press:active {
  transform: scale(0.95);
}

/* Image zoom on hover */
.img-zoom {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-zoom:hover {
  transform: scale(1.05);
}

/* =============================================================================
   TIER BADGES
   ============================================================================= */

.tier-free {
  background: rgba(52, 199, 89, 0.1);
  color: #34C759;
}

.tier-starter {
  background: rgba(0, 122, 255, 0.1);
  color: #007AFF;
}

.tier-pro {
  background: rgba(175, 82, 222, 0.1);
  color: #AF52DE;
}

.tier-enterprise {
  background: rgba(255, 149, 0, 0.1);
  color: #FF9500;
}

/* =============================================================================
   SCROLLBAR & OVERFLOW
   ============================================================================= */

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hide scrollbar */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Search input clear button color */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  width: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239335EB' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
  cursor: pointer;
}

/* =============================================================================
   TEXT UTILITIES
   ============================================================================= */

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 50%, #AF52DE 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */

/* Promo bar marquee scroll */
@keyframes promo-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Fade up (for staggered lists) */
@keyframes fadeUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-up {
  animation: fadeUp 0.4s ease-out forwards;
}

/* Stagger animation delays */
.stagger-item { animation: fadeUp 0.4s ease-out forwards; }
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }
.stagger-item:nth-child(7) { animation-delay: 300ms; }
.stagger-item:nth-child(8) { animation-delay: 350ms; }

/* Shimmer loading */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.05) 25%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
}

/* Pulse soft */
@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.animate-pulse-soft {
  animation: pulseSoft 2s infinite;
}

/* =============================================================================
   SAFE AREAS (iOS notch)
   ============================================================================= */

.safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.safe-left {
  padding-left: env(safe-area-inset-left, 0px);
}

.safe-right {
  padding-right: env(safe-area-inset-right, 0px);
}

/* =============================================================================
   BOTTOM TAB BAR SPACING
   ============================================================================= */

/* Global mobile bottom tabs are fixed-position; add scroll space so content isn't obscured. */
@media (max-width: 1023px) {
  body.has-bottom-tabs {
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* =============================================================================
   RESPONSIVE UTILITIES
   ============================================================================= */

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .card-hover:hover {
    transform: none;
    box-shadow: none;
  }

  .img-zoom:hover {
    transform: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print */
@media print {
  header,
  footer,
  nav {
    display: none;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  body {
    background: white;
    color: black;
  }
}

/* =============================================================================
   GLOBAL NAV DRAWER (Hamburger)
   ============================================================================= */

html.global-nav-loading header.glass,
html.global-nav-loading header.sticky {
  opacity: 0;
}

html.global-nav-ready header.glass,
html.global-nav-ready header.sticky {
  opacity: 1;
  transition: opacity 120ms ease-out;
}

/* Hamburger button */
.hamburger-btn {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 0;
}

.hamburger-btn:hover {
  background: hsl(var(--secondary));
}

.hamburger-btn:active {
  transform: scale(0.95);
}

.hamburger-icon {
  width: 20px;
  height: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

/* Drawer overlay */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 100;
}

.nav-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Drawer */
.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: hsl(var(--card));
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 101;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-drawer.open {
  transform: translateX(0);
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid hsl(var(--border));
  position: sticky;
  top: 0;
  background: hsl(var(--card));
  z-index: 1;
  min-height: 60px;
}

.nav-drawer-title {
  font-size: 18px;
  font-weight: 700;
}

.nav-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.nav-drawer-close:hover {
  background: hsl(var(--muted));
}

.nav-drawer-close:active {
  transform: scale(0.95);
}

.nav-section {
  padding: 16px 20px;
  border-bottom: 1px solid hsl(var(--border));
}

.nav-section:last-child {
  border-bottom: none;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 12px;
}

.nav-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin: 4px 0;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 12px;
  background: hsl(var(--secondary) / 0.5);
}

.nav-menu-item:hover {
  background: hsl(var(--secondary));
}

.nav-menu-item:active {
  background: hsl(var(--muted));
  transform: scale(0.98);
}

.nav-menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.nav-menu-text {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.credits-shimmer {
  background: linear-gradient(
    90deg,
    hsl(var(--primary) / 0.1) 0%,
    hsl(var(--primary) / 0.3) 50%,
    hsl(var(--primary) / 0.1) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.credits-shimmer.loaded {
  animation: none;
  -webkit-text-fill-color: hsl(var(--primary));
  background: none;
}

/* =============================================================================
   MODEL CUSTOM SELECT (Agent Pages)
   ============================================================================= */

.model-custom-select {
  position: relative;
  width: 100%;
}

.model-custom-select.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.model-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 0.625rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
}

.model-select-trigger:hover:not(:disabled) {
  border-color: hsl(var(--muted-foreground) / 0.5);
}

.model-custom-select.open .model-select-trigger {
  border-color: hsl(var(--primary) / 0.5);
}

.model-select-trigger:focus {
  outline: none;
  border-color: hsl(var(--primary) / 0.5);
}

.model-select-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.model-select-value {
  font-weight: 500;
}

.model-select-arrow {
  width: 1rem;
  height: 1rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.model-custom-select.open .model-select-arrow {
  transform: rotate(180deg);
}

.model-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.model-custom-select.open .model-select-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.model-select-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: background 0.15s ease;
}

.model-select-option:hover {
  background: var(--panel-hover);
}

.model-select-option.selected {
  color: hsl(var(--primary));
}

.model-option-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
}

.model-option-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.model-select-option.selected .model-option-label::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid hsl(var(--primary));
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* =============================================================================
   FORM CUSTOM SELECT (Schema Form Fields)
   ============================================================================= */

.form-custom-select {
  position: relative;
  width: 100%;
}

.form-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 0.625rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
  text-align: left;
}

.form-select-trigger:hover {
  border-color: hsl(var(--muted-foreground) / 0.5);
}

.form-custom-select.open .form-select-trigger {
  border-color: hsl(var(--primary) / 0.5);
}

.form-select-trigger:focus {
  outline: none;
  border-color: hsl(var(--primary) / 0.5);
}

.form-select-value {
  font-weight: 500;
}

.form-select-arrow {
  width: 1rem;
  height: 1rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.form-custom-select.open .form-select-arrow {
  transform: rotate(180deg);
}

.form-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.form-custom-select.open .form-select-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.form-select-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: background 0.15s ease;
}

.form-select-option:hover {
  background: hsl(var(--muted));
}

.form-select-option.selected {
  color: hsl(var(--primary));
}

.form-option-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-select-option.selected .form-option-label::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid hsl(var(--primary));
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* =============================================================================
   MARKDOWN CONTENT (.ait-markdown)
   ============================================================================= */

.ait-markdown {
  line-height: 1.7;
  color: hsl(var(--foreground));
  overflow-wrap: break-word;
}

/* Headings */
.ait-markdown h1,
.ait-markdown h2,
.ait-markdown h3,
.ait-markdown h4,
.ait-markdown h5,
.ait-markdown h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
  line-height: 1.3;
  color: hsl(var(--foreground));
}

.ait-markdown h1 {
  font-size: 1.875rem;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0.5em;
}

.ait-markdown h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0.375em;
}

.ait-markdown h3 {
  font-size: 1.25rem;
}

.ait-markdown h4 {
  font-size: 1.125rem;
}

.ait-markdown h5,
.ait-markdown h6 {
  font-size: 1rem;
}

.ait-markdown h1:first-child,
.ait-markdown h2:first-child,
.ait-markdown h3:first-child,
.ait-markdown h4:first-child,
.ait-markdown h5:first-child,
.ait-markdown h6:first-child {
  margin-top: 0;
}

/* Paragraphs */
.ait-markdown p {
  margin-top: 0;
  margin-bottom: 1em;
}

.ait-markdown p:last-child {
  margin-bottom: 0;
}

/* Lists */
.ait-markdown ul,
.ait-markdown ol {
  margin-top: 0;
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.ait-markdown ul {
  list-style-type: disc;
}

.ait-markdown ol {
  list-style-type: decimal;
}

.ait-markdown li {
  margin-bottom: 0.375em;
  line-height: 1.6;
}

/* Bullet / number markers in the primary accent. */
.ait-markdown ul li::marker,
.ait-markdown ol li::marker {
  color: hsl(var(--primary));
}

.ait-markdown li:last-child {
  margin-bottom: 0;
}

/* Nested lists */
.ait-markdown ul ul,
.ait-markdown ol ol,
.ait-markdown ul ol,
.ait-markdown ol ul {
  margin-top: 0.375em;
  margin-bottom: 0.375em;
}

.ait-markdown ul ul {
  list-style-type: circle;
}

.ait-markdown ul ul ul {
  list-style-type: square;
}

/* Links */
.ait-markdown a {
  color: hsl(var(--primary));
  text-decoration: none;
  transition: color 0.15s ease;
}

.ait-markdown a:hover {
  text-decoration: underline;
}

/* Bold & Italic */
.ait-markdown strong,
.ait-markdown b {
  font-weight: 600;
}

.ait-markdown em,
.ait-markdown i {
  font-style: italic;
}
.ait-markdown pre {
  margin: 1em 0;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  background: hsl(var(--muted) / 0.5);
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.ait-markdown code {
  font-family: ui-monospace, monospace;
  font-size: 0.875em;
}

.ait-markdown :not(pre) > code {
  background: hsl(var(--muted) / 0.5);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}
/* Blockquotes */
.ait-markdown blockquote {
  margin: 0 0 1em;
  padding: 0.5em 1em;
  border-left: 4px solid hsl(var(--primary) / 0.5);
  background: hsl(var(--muted) / 0.5);
  border-radius: 0 0.375rem 0.375rem 0;
  color: hsl(var(--muted-foreground));
}

.ait-markdown blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal rule */
.ait-markdown hr {
  margin: 1.5em 0;
  border: none;
  border-top: 1px solid hsl(var(--border));
}

/* Tables */
.ait-markdown table {
  width: 100%;
  margin-bottom: 1em;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ait-markdown th,
.ait-markdown td {
  padding: 0.625rem 0.75rem;
  border: 1px solid hsl(var(--border));
  text-align: left;
}

.ait-markdown th {
  font-weight: 600;
  background: hsl(var(--muted));
}

.ait-markdown tr:nth-child(even) {
  background: hsl(var(--muted) / 0.3);
}

/* Images */
.ait-markdown img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.5em 0;
}

/* Task lists (checkboxes) */
.ait-markdown input[type="checkbox"] {
  margin-right: 0.5em;
  vertical-align: middle;
}

.ait-markdown ul:has(input[type="checkbox"]) {
  list-style: none;
  padding-left: 0.5em;
}

/* Strikethrough */
.ait-markdown del,
.ait-markdown s {
  text-decoration: line-through;
  color: hsl(var(--muted-foreground));
}

/* Subscript & Superscript */
.ait-markdown sub,
.ait-markdown sup {
  font-size: 0.75em;
}

/* Definition lists */
.ait-markdown dl {
  margin-bottom: 1em;
}

.ait-markdown dt {
  font-weight: 600;
  margin-top: 0.5em;
}

.ait-markdown dd {
  margin-left: 1.5em;
  margin-bottom: 0.5em;
}

/* =============================================================================
   AGENT PAGE TABS
   ============================================================================= */

.agent-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: hsl(var(--secondary));
  border-radius: 0.75rem;
}

.agent-tabs button {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: none;
}

.agent-tabs button[aria-selected="true"],
.agent-tabs button.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.agent-tabs button:hover:not([aria-selected="true"]):not(.active) {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.5);
}

/* =============================================================================
   SHOWCASE CAROUSEL
   ============================================================================= */

.showcase-carousel {
  position: relative;
  overflow: hidden;
}

.showcase-track {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding-bottom: 0.5rem;
  max-width: 100%;
}

/* Hero media thumbnail carousel */
.flex.items-center.gap-3.overflow-x-auto.hide-scrollbar {
  max-width: 100%;
}

@media (min-width: 640px) {
  .flex.items-center.gap-3.overflow-x-auto.hide-scrollbar {
    max-width: 160px;
  }
}

.showcase-track::-webkit-scrollbar {
  display: none;
}

.showcase-item {
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: transform 0.2s ease;
}

.showcase-item:hover {
  transform: scale(1.02);
}

/* =============================================================================
   CREATION HISTORY
   ============================================================================= */

.creation-history {
  display: grid;
  gap: 1rem;
}

.creation-history.view-list {
  grid-template-columns: 1fr;
}

.creation-history.view-list .creation-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  transition: background 0.15s ease;
}

.creation-history.view-list .creation-card:hover {
  background: hsl(var(--secondary));
}

.creation-history.view-list .creation-card-media {
  width: 120px;
  height: 90px;
  flex-shrink: 0;
  border-radius: 0.5rem;
  overflow: hidden;
}

.creation-history.view-list .creation-card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.creation-history.view-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.creation-history.view-grid .creation-card {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
}

.creation-history.view-grid .creation-card-media {
  width: 100%;
  height: 100%;
}

.creation-history.view-grid .creation-card-details {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: white;
}

.creation-history.view-grid .creation-card:hover .creation-card-details {
  opacity: 1;
}

.creation-card-media img,
.creation-card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

[data-agent-run-history] .creation-card {
  border-radius: 0.75rem;
}

.creation-card-details {
  padding: 1rem 1.25rem;
}

.creation-card-details .creation-badges {
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.creation-card-details .creation-badges span {
  padding: 0.375rem 0.75rem;
}

[data-run-prompt] {
  word-break: break-word;
  overflow-wrap: break-word;
  min-height: 6rem;
}

[data-run-prompt].font-mono {
  font-size: 0.8125rem;
  line-height: 1.5;
}

.creation-card-timestamp {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.creation-history.view-grid .creation-card-timestamp {
  color: rgba(255, 255, 255, 0.7);
}

.creation-card-model {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.creation-history.view-grid .creation-card-model {
  color: rgba(255, 255, 255, 0.6);
}

/* =============================================================================
   VIEW MODE TOGGLE
   ============================================================================= */

.view-toggle {
  display: inline-flex;
  gap: 0.125rem;
  padding: 0.25rem;
  background: hsl(var(--secondary));
  border-radius: 0.5rem;
}

.view-toggle-btn {
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-toggle-btn:hover {
  color: hsl(var(--foreground));
}

.view-toggle-btn.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* =============================================================================
   CREATION PREVIEW AREA
   ============================================================================= */

.creation-preview {
  aspect-ratio: 16/9;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.creation-preview img,
.creation-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.creation-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: hsl(var(--muted-foreground));
  text-align: center;
  padding: 2rem;
}

/* =============================================================================
   REMIX AREA GRID
   ============================================================================= */

.remix-grid {
  columns: 4;
  column-gap: 0.75rem;
}

.remix-item {
  display: block;
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  cursor: pointer;
  background: hsl(var(--secondary));
  text-decoration: none;
  color: inherit;
  break-inside: avoid;
  margin-bottom: 0.75rem;
}

.remix-item-media {
  width: 100%;
}

.remix-item-media img,
.remix-item-media video {
  width: 100%;
  display: block;
  object-fit: cover;
}

.remix-item img,
.remix-item video {
  min-height: 120px;
  object-fit: cover;
}

/* Mobile: show card overlay always since there's no hover, lighter gradient */
@media (hover: none) {
  .creations-card .from-black\/95,
  .remix-item .from-black\/95,
  #communityCreationsGrid .from-black\/95 {
    opacity: 1 !important;
    background-image: linear-gradient(to top, rgba(0,0,0,0.92), rgba(0,0,0,0.5), rgba(0,0,0,0.1)) !important;
  }
  .creations-card .translate-y-3,
  .remix-item .translate-y-3,
  #communityCreationsGrid .translate-y-3 {
    transform: translateY(0) !important;
  }
}

.remix-item-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.remix-action-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  color: white;
  transition: all 0.15s ease;
}

.remix-action-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.1);
}

.remix-action-btn svg {
  width: 1rem;
  height: 1rem;
}

.remix-item-video::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 50%;
}

.remix-item:hover .remix-item-video::after {
  opacity: 0;
}

@media (max-width: 640px) {
  .remix-grid {
    columns: 2;
    column-gap: 0.5rem;
  }

  .remix-item {
    margin-bottom: 0.5rem;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .remix-grid {
    columns: 3;
  }
}

/* =============================================================================
   AGENT PAGE 
   ============================================================================= */

/* Background removed - now uses page background */

[data-agent-run-root] > .grid {
  gap: 0.75rem;
}
@media (min-width: 1024px) {
  [data-agent-run-root] > .grid {
    gap: 1rem;
  }
}

.dark [data-agent-run-left] > div:first-child,
html.dark [data-agent-run-left] > div:first-child {
  background-color: #0F0F0F !important;
  background-image: none !important;
}

/* Opaque card background so rounded corners don't show page behind */
[data-agent-run-left] > div:first-child {
  background-color: #F2F5F9;
}
html.dark [data-agent-run-left] > div:first-child {
  background-color: #0F0F0F !important;
}

.dark [data-agent-run-form] input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
.dark [data-agent-run-form] select,
.dark .model-selector-wrap button,
html.dark [data-agent-run-form] input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
html.dark [data-agent-run-form] select,
html.dark .model-selector-wrap button {
  background-color: #141414 !important;
}

[data-agent-run-form] textarea {
  background: #E9EEF7 !important;
  border: none !important;
  border-radius: 0.75rem !important;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8125rem !important;
  color: #1a1a1a !important;
  margin: 0 !important;
  min-height: 8rem !important;
}

[data-agent-run-form] div:has(> textarea),
[data-agent-run-form] .relative:has(textarea) {
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

[data-agent-run-form] > * {
  margin-top: 0.375rem !important;
  margin-bottom: 0 !important;
}

[data-agent-run-form] > *:first-child {
  margin-top: 0 !important;
}

[data-agent-run-form] label {
  margin-bottom: 0.125rem !important;
}

[data-agent-run-form] .mb-3 {
  margin-bottom: 0.125rem !important;
}

/* Left panel typography*/
[data-agent-run-left],
[data-agent-run-form],
.model-selector-in-form,
.model-selector-wrap {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif !important;
}

/* Section titles */
[data-agent-run-form] label,
[data-agent-run-form] .mb-3 label,
[data-agent-run-form] > div > label,
.model-selector-wrap .agent-form-section-label {
  font-size: 11px !important;
  font-weight: 400 !important;
  color: #6b7280 !important;
}
.dark [data-agent-run-form] label,
.dark [data-agent-run-form] .mb-3 label,
.dark [data-agent-run-form] > div > label,
.dark .model-selector-wrap .agent-form-section-label,
html.dark [data-agent-run-form] label,
html.dark [data-agent-run-form] .mb-3 label,
html.dark [data-agent-run-form] > div > label,
html.dark .model-selector-wrap .agent-form-section-label {
  color: #9ca3af !important;
}

/* Upload title */
.agent-form-upload-title {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #1a1a1a !important;
}
.dark .agent-form-upload-title,
html.dark .agent-form-upload-title {
  color: #FFFFFF !important;
}

/* Hint/description */
.agent-form-hint,
[data-agent-run-form] .agent-form-hint,
.model-selector-wrap .agent-form-hint {
  font-size: 11px !important;
  font-weight: 500 !important;
  color: #898A8B !important;
}

/* Model contents, More options, toggles */
.agent-form-value,
.model-selector-wrap .agent-form-value,
[data-agent-run-form] details summary .agent-form-value {
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #1a1a1a !important;
}
.dark .agent-form-value,
.dark .model-selector-wrap .agent-form-value,
.dark [data-agent-run-form] details summary .agent-form-value,
html.dark .agent-form-value,
html.dark .model-selector-wrap .agent-form-value,
html.dark [data-agent-run-form] details summary .agent-form-value {
  color: #FFFFFF !important;
}

/* Dropdown/select and options */
[data-agent-run-form] [role="option"],
.model-selector-in-form [role="option"] {
  font-size: 13px !important;
  font-weight: 500 !important;
}

/* More options disclosure */
[data-agent-run-form] details label,
[data-agent-run-form] details .agent-form-value {
  font-size: 13px !important;
  font-weight: 500 !important;
}
.dark [data-agent-run-form] details label,
.dark [data-agent-run-form] details .agent-form-value,
html.dark [data-agent-run-form] details label,
html.dark [data-agent-run-form] details .agent-form-value {
  color: #FFFFFF !important;
}

.dark [data-agent-run-form] textarea,
html.dark [data-agent-run-form] textarea {
  background-color: #141414 !important;
  color: #fff !important;
}

[data-agent-run-form] textarea::placeholder {
  color: #9ca3af !important;
}

.dark [data-agent-run-form] textarea::placeholder,
html.dark [data-agent-run-form] textarea::placeholder {
  color: #6b7280 !important;
}

[data-agent-run-left] > div > div:last-child {
  padding: 0 0.375rem 0.375rem 0.375rem !important;
  border-radius: 0 0 24px 24px !important; /* match card bottom radius */
  background-color: #F2F5F9;
}
@media (max-width: 1023px) {
  [data-agent-run-left] > div > div:last-child {
    padding: 0.375rem 0 !important;
  }
}
html.dark [data-agent-run-left] > div > div:last-child,
.dark [data-agent-run-left] > div > div:last-child {
  background-color: #0F0F0F !important;
}

[data-agent-run-form],
[data-mobile-form-content],
.model-selector-in-form {
  overflow: visible !important;
}

[data-agent-run-left] > div:first-child {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  border-radius: 24px !important;
}
html.dark [data-agent-run-left] > div:first-child,
.dark [data-agent-run-left] > div:first-child {
  border-color: #171717 !important;
}

@media (max-width: 1023px) {
  [data-agent-run-left] > div:first-child {
    overflow-y: visible !important;
    max-height: none !important;
    position: static !important;
    top: auto !important;
  }
}

[data-agent-run-form] .grid.grid-cols-2 {
  gap: 0.75rem !important;
  align-items: start;
}
[data-agent-run-form] .grid.grid-cols-2 .media-field-header {
  min-height: 2.5rem;
  display: flex;
  align-items: flex-end;
}

[data-agent-run-left] > div > .relative[class*="aspect-"] {
  border-radius: 24px 24px 24px 24px !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
}

[data-agent-run-left] > div > .relative[class*="aspect-"] img,
[data-agent-run-left] > div > .relative[class*="aspect-"] video,
[data-agent-run-left] > div > .relative[class*="aspect-"] .bg-gradient-to-t {
  border-radius: 24px 24px 24px 24px !important;
}

[data-agent-run-form] > details,
[data-agent-run-form] > form > details {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem !important;
  border-radius: 0;
  background: transparent;
  border: none;
}

[data-agent-run-button] {
  margin-top: 0.5rem !important;
}

[data-agent-run-form] label,
[data-agent-run-form] .mb-3 label,
[data-agent-run-form] > div > label {
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  color: #374151 !important;
}

.dark [data-agent-run-form] label,
.dark [data-agent-run-form] .mb-3 label,
.dark [data-agent-run-form] > div > label,
html.dark [data-agent-run-form] label,
html.dark [data-agent-run-form] .mb-3 label,
html.dark [data-agent-run-form] > div > label {
  color: #d1d5db !important;
}

[data-agent-run-form] select,
[data-agent-run-form] .model-selector-wrap button,
.model-selector-in-form button {
  width: 100%;
  height: 3rem;
  padding: 0 1rem;
  border-radius: 0.75rem;
  background: #E9EEF7 !important;
  border: none !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #1a1a1a;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.dark [data-agent-run-form] select,
.dark [data-agent-run-form] .model-selector-wrap button,
.dark .model-selector-in-form button,
html.dark [data-agent-run-form] select,
html.dark [data-agent-run-form] .model-selector-wrap button,
html.dark .model-selector-in-form button {
  background: #141414 !important;
  color: #fff;
}

.dark [data-agent-run-form] .model-selector-wrap button:hover,
.dark .model-selector-in-form button:hover,
html.dark [data-agent-run-form] .model-selector-wrap button:hover,
html.dark .model-selector-in-form button:hover {
  background: #1A1C1F !important;
}

[data-agent-run-form] [role="listbox"],
[data-agent-run-form] .dropdown-menu,
.model-selector-in-form [role="listbox"],
.model-selector-in-form .dropdown-menu {
  background: #fff !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12) !important;
  padding: 0.375rem !important;
  margin-top: 0.25rem !important;
}

.dark [data-agent-run-form] [role="listbox"],
.dark [data-agent-run-form] .dropdown-menu,
.dark .model-selector-in-form [role="listbox"],
.dark .model-selector-in-form .dropdown-menu,
html.dark [data-agent-run-form] [role="listbox"],
html.dark [data-agent-run-form] .dropdown-menu,
html.dark .model-selector-in-form [role="listbox"],
html.dark .model-selector-in-form .dropdown-menu {
  background: #141414 !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

[data-agent-run-form] [role="option"],
.model-selector-in-form [role="option"] {
  padding: 0.75rem 1rem !important;
  border-radius: 0.5rem !important;
  font-size: 0.875rem !important;
  cursor: pointer;
  transition: background 0.15s ease;
}

[data-agent-run-form] [role="option"]:hover,
.model-selector-in-form [role="option"]:hover {
  background: #E9EEF7 !important;
}

.dark [data-agent-run-form] [role="option"]:hover,
.dark .model-selector-in-form [role="option"]:hover,
html.dark [data-agent-run-form] [role="option"]:hover,
html.dark .model-selector-in-form [role="option"]:hover {
  background: #1A1C1F !important;
}

[data-agent-run-form] [role="option"][aria-selected="true"],
.model-selector-in-form [role="option"][aria-selected="true"] {
  background: #E9EEF7 !important;
}

.dark [data-agent-run-form] [role="option"][aria-selected="true"],
.dark .model-selector-in-form [role="option"][aria-selected="true"],
html.dark [data-agent-run-form] [role="option"][aria-selected="true"],
html.dark .model-selector-in-form [role="option"][aria-selected="true"] {
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Model selector: family trigger + model picker button hover */
.family-trigger:hover,
.family-item .family-trigger:hover {
  background: var(--panel-hover) !important;
}
[data-model-picker-modal] button:hover {
  background: var(--panel-hover) !important;
}

/* Model selector: list items and flyout items */
.model-selector-dropdown .model-selector-list-item {
  background: transparent !important;
}
.model-selector-dropdown .model-selector-list-item:hover,
.model-selector-dropdown .model-selector-list-item.model-selector-item-selected {
  background: #DDE4ED !important;
}
.dark .model-selector-dropdown .model-selector-list-item,
html.dark .model-selector-dropdown .model-selector-list-item {
  background: transparent !important;
}
.dark .model-selector-dropdown .model-selector-list-item:hover,
.dark .model-selector-dropdown .model-selector-list-item.model-selector-item-selected,
html.dark .model-selector-dropdown .model-selector-list-item:hover,
html.dark .model-selector-dropdown .model-selector-list-item.model-selector-item-selected {
  background: #1A1C1F !important;
}

.model-selector-flyout .model-selector-flyout-item {
  background: #EAEFF7 !important;
  border-color: transparent !important;
  height: auto !important;
  min-height: 100px !important;
}
.model-selector-flyout .model-selector-flyout-item:hover {
  background: #DDE4ED !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}
.model-selector-flyout .model-selector-flyout-item.model-selector-item-selected {
  background: #DDE4ED !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
}
.dark .model-selector-flyout .model-selector-flyout-item,
html.dark .model-selector-flyout .model-selector-flyout-item {
  background: #141414 !important;
  border-color: transparent !important;
}
.dark .model-selector-flyout .model-selector-flyout-item:hover,
.dark .model-selector-flyout .model-selector-flyout-item.model-selector-item-selected,
html.dark .model-selector-flyout .model-selector-flyout-item:hover,
html.dark .model-selector-flyout .model-selector-flyout-item.model-selector-item-selected {
  background: #1A1C1F !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.dark [data-agent-run-form] > details,
.dark [data-agent-run-form] > form > details,
html.dark [data-agent-run-form] > details,
html.dark [data-agent-run-form] > form > details {
  background: transparent;
  border: none;
}

[data-agent-run-form] > details > summary,
[data-agent-run-form] > form > details > summary {
  padding: 0.75rem 0.75rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px !important;
  color: #374151;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dark [data-agent-run-form] > details > summary,
.dark [data-agent-run-form] > form > details > summary,
html.dark [data-agent-run-form] > details > summary,
html.dark [data-agent-run-form] > form > details > summary {
  color: #d1d5db;
}

[data-agent-run-form] > details > summary::-webkit-details-marker,
[data-agent-run-form] > form > details > summary::-webkit-details-marker {
  display: none;
}

[data-agent-run-form] > details > summary:has(svg)::after,
[data-agent-run-form] > form > details > summary:has(svg)::after {
  display: none !important;
}

[data-agent-run-form] > details > summary:not(:has(svg))::after,
[data-agent-run-form] > form > details > summary:not(:has(svg))::after {
  content: '';
  width: 1.25rem;
  height: 1.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23888' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  transition: transform 0.2s ease;
  margin-left: auto;
}

[data-agent-run-form] > details[open] > summary:not(:has(svg))::after,
[data-agent-run-form] > form > details[open] > summary:not(:has(svg))::after {
  transform: rotate(180deg);
}

[data-agent-run-form] > details > div,
[data-agent-run-form] > details > .space-y-4,
[data-agent-run-form] > details > .space-y-3,
[data-agent-run-form] > form > details > div,
[data-agent-run-form] > form > details > .space-y-4,
[data-agent-run-form] > form > details > .space-y-3 {
  padding: 0.5rem 0 0.75rem 0;
}

[data-agent-run-form] > details > div > * + *,
[data-agent-run-form] > details > .space-y-4 > * + *,
[data-agent-run-form] > details > .space-y-3 > * + *,
[data-agent-run-form] > form > details > div > * + *,
[data-agent-run-form] > form > details > .space-y-4 > * + *,
[data-agent-run-form] > form > details > .space-y-3 > * + * {
  margin-top: 0.5rem !important;
}

[data-agent-run-form] > details .space-y-4,
[data-agent-run-form] > form > details .space-y-4 {
  --tw-space-y-reverse: 0;
  margin-top: 0 !important;
}

[data-agent-run-form] > details .space-y-4 > * + *,
[data-agent-run-form] > form > details .space-y-4 > * + * {
  margin-top: 0.5rem !important;
}

[data-agent-run-form].space-y-3 > * + * {
  margin-top: 0.375rem !important;
}

[data-mobile-form-content].space-y-3 > * + * {
  margin-top: 0.375rem !important;
}

[data-agent-run-form] > *:first-child {
  margin-top: 0 !important;
}

[data-agent-run-form] div:has(> .rounded-2xl button.dropzone-empty) > .mb-3:first-child,
[data-agent-run-form] div:has(> .rounded-2xl .dropzone-empty) > .mb-3:first-child,
[data-agent-run-form] div:has(button.dropzone-empty) > .mb-3:first-child {
  display: none !important;
}
[data-agent-run-form] div:has(> .rounded-2xl button.dropzone-empty) > .media-field-header:first-child,
[data-agent-run-form] div:has(> .rounded-2xl .dropzone-empty) > .media-field-header:first-child,
[data-agent-run-form] div:has(button.dropzone-empty) > .media-field-header:first-child {
  display: flex !important;
  align-items: center;
  margin-bottom: 0.5rem;
}
.media-field-header label {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

html.dark button.dropzone-empty,
html.dark .dropzone-empty,
.dark button.dropzone-empty,
.dark .dropzone-empty,
html.dark [data-agent-run-form] button.dropzone-empty,
html.dark [data-agent-run-form] .dropzone-empty {
  background-color: #141414 !important;
  background: #141414 !important;
}
html.dark button.dropzone-empty:hover,
.dark button.dropzone-empty:hover {
  background-color: #1a1c1f !important;
  background: #1a1c1f !important;
}

html.dark [data-agent-run-form] input[type="url"],
.dark [data-agent-run-form] input[type="url"] {
  background-color: #1C1E20 !important;
  background: #1C1E20 !important;
}

[data-agent-run-left] > div > .relative[class*="aspect-"] {
  border-radius: 24px;
}
[data-agent-run-left] > div > .relative[class*="aspect-"] img,
[data-agent-run-left] > div > .relative[class*="aspect-"] video,
[data-agent-run-left] > div > .relative[class*="aspect-"] .bg-gradient-to-t {
  border-radius: 24px;
}

[data-agent-run-left] > div > div:last-child {
  padding: 0.75rem 1rem;
  border-radius: 0 0 24px 24px !important;
}
@media (max-width: 1023px) {
  [data-agent-run-left] > div > div:last-child {
    padding: 0.75rem 0;
  }
}
[data-agent-run-left] > div > div:last-child > * + * {
  margin-top: 0.75rem;
}
[data-agent-run-left] [data-agent-run-form] > * + * {
  margin-top: 0.75rem;
}

.model-selector-in-form {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}
.model-selector-in-form .model-selector-wrap {
  margin-bottom: 0;
}
.model-selector-in-form > p {
  display: none;
}

[data-agent-run-right] > div:first-child {
  margin-bottom: 0.75rem;
}
@media (min-width: 1024px) {
  [data-agent-run-right] > div:first-child {
    margin-bottom: 1rem;
  }
}
[data-agent-run-right] [data-agent-run-panel] {
  margin-top: 0;
}

[data-agent-run-creations] > div:first-child {
  padding: 0.75rem 1rem;
}
[data-agent-run-creations] [data-remix-content] {
  padding: 0.75rem 1rem 0;
}

[data-history-list-view][data-agent-run-history] {
  gap: 1rem !important;
}

[data-agent-run-history] .history-empty-state,
[data-agent-run-creations] .remix-grid .col-span-full.text-center {
  padding-top: 2.5rem !important;
  padding-bottom: 2.5rem !important;
}

[data-agent-run-output] {
  margin-bottom: 1rem !important;
}
[data-agent-run-output]:empty {
  margin-bottom: 0 !important;
}

/* History output panel sizing + media containment */
[data-agent-run-panel="history"] [data-agent-run-output].history-output-height {
  min-height: clamp(320px, 55vh, 680px);
  max-height: clamp(320px, 70vh, 640px);
}
@media (min-width: 1024px) {
  [data-agent-run-panel="history"] [data-agent-run-output].history-output-height {
    min-height: 0;
    height: min(var(--left-panel-height, 589px), 640px);
    max-height: 640px;
  }
}
[data-agent-run-panel="history"] [data-agent-run-output].history-output-media-contained {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}
[data-agent-run-panel="history"] [data-agent-run-output].history-output-media-contained img,
[data-agent-run-panel="history"] [data-agent-run-output].history-output-media-contained video {
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  margin-left: auto;
  margin-right: auto;
}
[data-agent-run-panel="history"] [data-agent-run-output].history-output-media-contained audio {
  width: min(100%, 720px);
}

/* =============================================================================
   AGENT PAGE RESPONSIVE
   ============================================================================= */

@media (max-width: 1023px) {
  [data-agent-run-root] > .grid {
    grid-template-columns: 1fr;
  }

  [data-agent-run-left] {
    order: 1;
  }

  [data-agent-run-right] {
    order: 2;
  }
}

@media (max-width: 640px) {
  .creation-history.view-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .creation-history.view-list .creation-card-media {
    width: 80px;
    height: 60px;
  }

  .showcase-item {
    width: 160px;
  }
}

/* =============================================================================
   MOBILE MASONRY LAYOUT
   ============================================================================= */

@media (max-width: 639px) {
  /* Masonry-style 2-column grid with varied heights */
  .masonry-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 8px;
    grid-auto-flow: dense;
    gap: 6px;
  }
  .masonry-grid .agent-card {
    background: hsl(var(--card)) !important;
    border: 1px solid hsl(var(--border) / 0.3) !important;
    overflow: hidden;
  }
  .masonry-grid .card-info {
    padding: 10px 12px 12px !important;
    background: hsl(var(--card));
  }
  .masonry-grid .card-info h3 {
    font-size: 13px !important;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 2px 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .masonry-grid .card-info p {
    font-size: 11px !important;
    line-height: 1.3;
    margin: 0 !important;
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block !important;
  }

  .masonry-grid .card-info > div {
    display: none !important;
  }
  .masonry-grid .agent-card {
    border-radius: 16px;
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .masonry-grid .agent-card:nth-child(odd) { grid-column: 1; }
  .masonry-grid .agent-card:nth-child(even) { grid-column: 2; }

  .masonry-grid .card-media {
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
  }
  .masonry-grid .card-media img,
  .masonry-grid .card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .masonry-grid .agent-card { grid-row: span 15; }

  .masonry-grid .popular-badge {
    padding: 3px 8px;
    font-size: 9px;
    top: 6px;
    left: 6px;
    background: hsl(var(--primary) / .85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

/* =============================================================================
   MOBILE DRAWER - Agent Form Slide-in Panel
   ============================================================================= */

/* When drawer is open: hide page scroll and any content behind */
body.drawer-open {
  overflow: hidden !important;
  height: 100% !important;
  position: fixed !important;
  width: 100% !important;
}

/* Drawer/backdrop naming is legacy; also support generic run panel */
/* Backdrop - hidden (panel is inline on all breakpoints) */
.run-panel-backdrop {
  display: none;
}

/* Mobile: form inline (no drawer). Same layout as desktop: form + Generate in left column. */
@media (max-width: 1023px) {
  /* Hide "Start Creating" button - inputs are shown directly */
  [data-mobile-form-toggle] {
    display: none !important;
  }

  /* Backdrop never shown */
  .run-panel-backdrop {
    display: none !important;
    visibility: hidden !important;
  }

  /* Form block: static, visible (same as desktop) */
  [data-run-panel].run-panel,
  div.run-panel,
  .run-panel {
    position: static !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    z-index: auto !important;
    display: block !important;
    flex-direction: unset !important;
    isolation: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Hide header (agent picker + close) on mobile; use "Change" on image */
  .run-panel-header {
    display: none !important;
  }

  /* Hide mobile drawer footer; use desktop-generate-wrapper instead */
  .run-panel-footer {
    display: none !important;
    position: static !important;
  }

  .run-panel-body {
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Generate button sticky at bottom on mobile */
  .desktop-generate-wrapper {
    display: block !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 30 !important;
    padding: 1rem 0 0.5rem !important;
    margin: 0 !important;
    background: linear-gradient(to bottom, transparent 0%, #F2F5F9 30%) !important;
  }
  html.dark .desktop-generate-wrapper,
  .dark .desktop-generate-wrapper {
    background: linear-gradient(to bottom, transparent 0%, #0F0F0F 30%) !important;
  }

  body.drawer-open {
    overflow: auto !important;
    position: static !important;
  }
}

/* Desktop: Reset all drawer styles completely */
@media (min-width: 1024px) {
  .run-panel-backdrop {
    display: none !important;
    visibility: hidden !important;
  }

  .run-panel {
    position: static !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    z-index: auto !important;
    display: block !important;
    flex-direction: unset !important;
    isolation: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .run-panel-header {
    display: none !important;
  }

  .run-panel-footer {
    display: none !important;
    position: static !important;
  }

  /* Make the left panel card a scrollable flex column */
  [data-agent-run-left] > .sticky {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    max-height: calc(100dvh - 10rem) !important;
  }

  [data-agent-run-left] > .sticky > .p-3 {
    flex: 1 !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
    min-height: 0 !important;
  }

  [data-agent-run-left] > .sticky > .p-3::-webkit-scrollbar {
    display: none !important;
  }

  .run-panel-body {
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Generate button sticky at bottom of scrollable left panel */
  .desktop-generate-wrapper {
    display: block !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 30 !important;
    padding: 1rem 0 0.5rem !important;
    margin: 0 !important;
    background: linear-gradient(to bottom, transparent 0%, #F2F5F9 30%) !important;
  }
  html.dark .desktop-generate-wrapper,
  .dark .desktop-generate-wrapper {
    background: linear-gradient(to bottom, transparent 0%, #0F0F0F 30%) !important;
  }

  body.drawer-open {
    overflow: auto !important;
    position: static !important;
  }
}

/* Prevent iOS Safari auto-zoom on input focus */
@media screen and (max-width: 767px) {
  [data-agent-run-form] input[type="text"],
  [data-agent-run-form] input[type="number"],
  [data-agent-run-form] input[type="url"],
  [data-agent-run-form] input[type="email"],
  [data-agent-run-form] textarea,
  [data-agent-run-form] select {
    font-size: 16px !important;
  }
}

/* CSP-compliant hover utility classes (replaces inline onmouseover/onmouseout) */
.hover-fade:hover { opacity: 0.9; }
.hover-bg-secondary:hover { background: hsl(var(--secondary) / 0.8); }
.hover-bg-danger:hover { background: rgba(239, 68, 68, 0.1); }

/* lazy-media: card videos inherit border-radius from their host card so the
 * script doesn't need to write an inline style per element. */
.lazy-media-video { border-radius: inherit; }

/* Skip rendering work for off-screen cards across the site (agents grid,
 * model grids, community/output grids, owner/provider listings). The
 * browser still keeps them in the DOM and includes them for find-in-page
 * and a11y, but skips style/layout/paint until the card scrolls near the
 * viewport.
 *
 * `contain-intrinsic-size: auto 400px` tells the browser: use 400px as the
 * placeholder height the first time a card is off-screen, but once the card
 * has rendered at least once, remember its actual size and use that instead.
 * This avoids scrollbar jumps regardless of card type (agent, model,
 * provider, community) without needing per-type tuning.
 *
 * `auto` keyword: Chrome/Edge/Opera 105+, Safari 18+. Older browsers fall
 * back to the 400px hint. content-visibility itself is ignored on browsers
 * that don't support it, so visual output is unchanged everywhere. */
/* All card types share content-visibility: only their initial-size hints
 * differ. The `auto` keyword tells the browser to remember each card's
 * actual measured size after the first render, so the second value below
 * is only used for cards that haven't been on screen yet — getting it in
 * the right ballpark prevents scrollbar jumps on first scroll. */
.agent-card,
.model-card,
.provider-card,
.community-card,
.creations-card {
  content-visibility: auto;
}

/* Square media (~340px) + info row (h3 + p + price/button row). */
.agent-card     { contain-intrinsic-size: auto 460px; }

/* 16:10 media (~210px on a 340px-wide card) + info section. */
.model-card     { contain-intrinsic-size: auto 320px; }

/* Single flex row: icon (56px) + padding. Very short. */
.provider-card  { contain-intrinsic-size: auto 96px;  }

/* Aspect-square media on the /store community grid, smaller than agent. */
.community-card { contain-intrinsic-size: auto 250px; }

/* Masonry layout — heights vary per image aspect ratio. Leave the second
 * value off so the browser uses a 0px hint until the card is measured;
 * `auto` then takes over and remembers the real size. */
.creations-card { contain-intrinsic-size: auto; }
